<?php
include "conexao.php";
$_SESSION[] = array();
session_start();

if(isset($_POST['logar']))
{
	$user = $_POST['user'];
	$pwd = $_POST['password'];	
}

$sql = "Select user,senha from usuarios where user LIKE '$user'";

$dados = mysql_query($sql);

$dados = mysql_fetch_array($dados);

if($dados[1] == $_POST['password'])
{
	header('location: principal.php');
	$_SESSION["usuario"] = $_POST['user'];
	echo "logado";
} else {
	header('location: index.php');
	$_SESSION["usuario"] = array();
}